#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct S{
	string s1;
	string s2;
	int a;
	int b;
	int c;
	int total = 0;
}arr[110];
bool cmp(struct S s3,struct S s4){
	if(s3.total > s4.total)
	return 1;
	else return 0;
}
int main(){
	int n,sum1 = 0,sum2 = 0,sum3 = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> arr[i].s1 >> arr[i].s2 >> arr[i].a >>arr[i].b >> arr[i].c;
		sum1 += arr[i].a;
		sum2 += arr[i].b;
		sum3 += arr[i].c;
		arr[i].total = arr[i].a + arr[i].b + arr[i].c;
	}
	sort(arr,arr + n,cmp);
	cout << sum1 / n << ' ' << sum2 / n << ' ' << sum3 / n <<endl;
	cout << arr[0].s1<<' '<<arr[0].s2<<' '<<arr[0].a<<' '<<arr[0].b<<' '<<arr[0].c;
	return 0;
}
